package com.itheima.mapper;

import com.itheima.pojo.CheckItem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckItemMapper {
    @Select("insert into t_checkitem(code,name,sex,age,price,remark,attention,type) values(#{code},#{name},#{sex},#{age},#{price},#{remark},#{attention},#{type})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void add(CheckItem checkItem);
@Delete("delete from t_checkitem where id = #{id}")
    int delete(Integer id);

    void edit(CheckItem checkItem);

    List<CheckItem> findPage(String queryString);
@Select("select * from t_checkitem")
    List<CheckItem> findAll();
@Select("select * from t_checkitem where id = #{id}")
    CheckItem findById(Integer id);
@Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{checkgroupId}")
    List<Integer> findCheckItemIdsByCheckGroupId(Integer checkgroupId);
@Select("select count(1) from t_checkgroup_checkitem where checkitem_id = #{id}")
    int findCountByCheckItemId(Integer id);
@Delete("delete from t_checkgroup_checkitem where checkitem_id = #{itemId} and checkgroup_id = #{id}")
    void deleteById(Integer itemId, Integer id);
}
